package com.senthink.gl.business.device;

/**
 * ZigBee/RFID设备在线/离线状态枚举类
 *
 * @author zooqi@senthink.com
 * @date 2017/12/27
 */
public enum StateEnum {

    /**
     * 在线
     */
    ONLINE,

    /**
     * 离线
     */
    OFFLINE;

    /**
     * @param state
     * @return
     */
    public static StateEnum fromState(String state) {
        switch (state) {
            case "ON":
                return StateEnum.ONLINE;
            case "OFF":
                return StateEnum.OFFLINE;
            default:
                throw new IllegalArgumentException("No such state type!");
        }
    }

    /**
     * 是否在线
     *
     * @param state
     * @return
     */
    public static boolean isOnline(String state) {
        switch (state) {
            case "ON":
                return true;
            case "OFF":
                return false;
            default:
                throw new IllegalArgumentException("No such state type!");
        }
    }
}
